home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
macros
/
latex209
/
contrib
/
slatex
/
config.ss
< prev
next >
Wrap
Text File
|
1993-11-07
|
6KB
|
213 lines
;config.ss
;Configures SLaTeX for your system
;(c) Dorai Sitaram, December 1991, Rice University
;IMPORTANT: You need to change only the lines defining the variables
; *dialect* and *op-sys*
;After making the changes, this file can be loaded in any RnRS
;Scheme, or Common Lisp.
;Enter Scheme (or Lisp), and type (load "config.ss"). This creates
;slatex.ss in the current directory.
(if (not 'nil)
;this is a kludge to test if you're in Scheme or in CL.
;if the latter, load CL procedures that emulate Scheme
;so the remaining stuff can be recognized by CL
(load "funval.cl")
'ok)
(if (not 'nil)
;continues the good work begun by the previous sexp
(load "rnrscl.cl")
'ok)
(define *dialect* 'scmj)
(define *op-sys* 'dos)
(load "preproc.ss")
(if (not 'nil) (set! *dialect* 'cl))
(define eoln
(cond ((eq? *op-sys* 'unix) (string #\newline))
((eq? *op-sys* 'dos) (string #\return #\newline))
(else (string #\newline))))
(define display*
(lambda (p . z)
(if p (for-each (lambda (x) (display x p)) z)
(for-each display z))))
(define reader-request
(lambda (request choices action default)
(request)
(let loop ()
(let ((user-input (read)))
(if (memq user-input choices)
(action user-input)
(if default
(begin
(display* #f user-input " not supported -- choosing "
default "." eoln)
(action default))
(begin
(display* #f "Please type one of " choices "." eoln)
(loop))))))))
(reader-request
(lambda ()
(display* #f eoln "Dialect specified as " *dialect* " -- approved? "
"Answer y(es) or n(o)." eoln))
'(y yes n no)
(lambda (user-input)
(if (memq user-input '(y yes)) 'ok
(reader-request
(lambda ()
(display* #f eoln "Type name of dialect -- should be one of" eoln
" chez cl cscheme elk schemetoc scmj umbscheme other." eoln
" (For details, please see install.doc.)" eoln))
'(chez cl cscheme elk schemetoc scmj umbscheme other)
(lambda (user-input)
(set! *dialect* user-input))
'other)))
#f)
(reader-request
(lambda ()
(display* #f eoln "Operating system specified as " *op-sys*
" -- approved? Answer y(es) or n(o)." eoln))
'(y yes n no)
(lambda (user-input)
(if (memq user-input '(y yes)) 'ok
(reader-request
(lambda ()
(display* #f eoln "Type name of system -- should be one of" eoln
" unix dos." eoln))
'(unix dos)
(lambda (user-input)
(set! *op-sys* user-input))
'unix)))
#f)
(display* #f eoln "Beginning configuring SLaTeX -- wait..." eoln)
(define transmit
(lambda (x out)
(write (preprocess-macros x) out)))
(define select
(lambda (in out)
(let loop ()
(let ((x (read in)))
(cond ((eof-object? x) 'done)
((and (pair? x) (eq? (car x) 'quote)
(pair? (cdr x)) (null? (cddr x))
(pair? (cadr x))
(memq (caadr x) '(enable disable)))
(let* ((dialects (cdadr x))
(y (read in))
(shd-extract?
(let ((isin? (memq *dialect* dialects)))
(if (eq? (caadr x) 'enable)
isin?
(not isin?)))))
(if shd-extract?
(begin (transmit y out) (newline out))
'do-not-extract)
(loop)))
(else (transmit x out) (newline out) (loop)))))))
(define port-copy
(lambda (in out)
(let loop ()
(let ((x (read in)))
(if (eof-object? x) 'done
(begin (write x out) (newline out) (loop)))))))
(define generate-compatible-file
(lambda (output-file)
(cond ((memq *dialect* '(chez cscheme scmj))
(if (file-exists? output-file)
(delete-file output-file) 'ok))
((eq? *dialect* 'cl)
(if (probe-file output-file)
(delete-file output-file) 'ok))
(else
(display* #f eoln
"If configuring fails following this sentence," eoln
"you most likely already have a slatex.ss in the current "
"directory." eoln
"Delete it and retry." eoln)))
(call-with-output-file output-file
(lambda (out)
;begin banner
(display* out
";slatex.ss file generated using config.ss" eoln
";This file is compatible for the dialect " *dialect* eoln
";(c) dorai@rice.edu Dec. 1991" eoln eoln)
;end banner
(if (eq? *dialect* 'cl)
(begin
(call-with-input-file "funval.cl"
(lambda (in)
(port-copy in out)))
(call-with-input-file "rnrscl.cl"
(lambda (in)
(port-copy in out))))
'using-scheme)
(display* out "(define *op-sys* '"
(cond ((eq? *op-sys* 'unix) 'unix)
((eq? *op-sys* 'dos) 'dos)
(else 'unix)) ;assume it's unix-like
")" eoln)
(for-each
(lambda (file)
(call-with-input-file file
(lambda (in)
(select in out))))
(list
"optchez.ss"
"seqprocs.ss"
"fileproc.ss"
"lerror.ss"
"helpers.ss"
"defaults.ss"
"structs.ss"
"peephole.ss"
"codeset.ss"
"pathproc.ss"
"texread.ss"
"proctex.ss"
"proctex2.ss"))
))))
(generate-compatible-file
(if (eq? *dialect* 'chez) "temp.ss" "slatex.ss"))
(if (eq? *dialect* 'chez)
(begin
(display* #f eoln
"Getting compiled version for Chez Scheme..." eoln)
(compile-file "temp.ss" "slatex.ss")
(delete-file "temp.ss")
(display* #f "Finished compilation." eoln))
'ok)
(display* #f eoln
"Finished configuring SLaTeX for your machine." eoln
"Read install.doc for details on" eoln
" a) which paths to place the SLaTeX files in;" eoln
" b) how to modify the given batch file or shell script "
"that invokes SLaTeX." eoln)
(cond ((memq *dialect* '(chez scmj)) (exit))
((eq? *dialect* 'cscheme) (%exit))
(else (display* #f "You may exit Scheme now!" eoln)))